/**
 * Copyright (c) 2020 xstgongyi.org
 * All rights reserved.
 */
package org.xstgongyi.eduaid.manager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.xstgongyi.eduaid.dao.ProjectMapper;
import org.xstgongyi.eduaid.dataobject.ProjectDO;

import java.util.List;

/**
 * @author oldcrane
 * @created 2020-10-12
 */
@Service
@CacheConfig(cacheNames = "project")
public class ProjectManager {

    @Autowired
    private ProjectMapper dao;

    @Cacheable(key = "'list-all'")
    public List<ProjectDO> listAll() {
        return dao.listAll();
    }

    @Cacheable(key = "#id")
    public ProjectDO getById(Integer id) {
        return dao.getById(id);
    }

    @CacheEvict(allEntries = true)
    public int insert(ProjectDO project) {
        return dao.insert(project);
    }

    @CacheEvict(allEntries = true)
    public int update(ProjectDO project) {
        return dao.update(project);
    }


}
